<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="com.jiadakeji.ppm.modules.sys.utils.*" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <title>发票查询</title>
    <meta name="decorator" content="default"/>
    <link href="${ctxStatic}/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <script src="${ctxStatic}/jquery-form/jquery.form.js" type="text/javascript"></script>
    <link href="${ctxStatic}/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/css/common.css" rel="stylesheet">
    <link href="${ctxStatic}/css/style.min.css?v=4.0.0" rel="stylesheet">
    <OBJECT ID=sk
            CLASSID="clsid:003BD8F2-A6C3-48EF-9B72-ECFD8FC4D49F"
            codebase="NISEC_SKSCX.ocx#version=1,0,0,1" width=0 height=0>
    </OBJECT>
    <script type="text/javascript">
        $(document).ready(function() {
            //$("#name").focus();
            $("#inputForm").validate({
                submitHandler: function(form){

                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
        });
    </script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="col-sm-12">
        <div class="tabs-container ">
            <ul class="nav nav-tabs">
                <input id="kpzdbs" name="kpzdbs" type="hidden" value="${counter}"/>
                <li class="active"><a href="${ctx}/invioce/invioceSearch">查询</a></li>
                <li><a href="${ctx}/invioce/invioceStatic">统计</a></li>
            </ul>
            <div class="tab-content right" >
            <div id="tab-1" class="tab-pane active">
                <div class="panel-body boxPanel">
                    <form:form id="searchForm" modelAttribute="findInvioceCondition" action="${ctx}/invioce/invioceSearch" method="post" class="breadcrumb form-search">
                        <ul class="ul-form">
                            <li>
                                <label>发票类型：</label>
                                <form:select path="fplxdm" cssClass="input-mediumSelect">
                                    <form:options items="${fns:getDictList('fplsdm') }" itemValue="value" itemLabel="label" />
                                </form:select>
                            </li>
                            <li>
                                <label>查询方式：</label>
                                <input type="radio" name="searchType" value="1" checked>时间查询
                                <input type="radio" name="searchType" value="0" >号码查询
                            </li>
                            <li>
                                <label class="control-label">查询日期：</label>
                                <input name="startDate" type="text" readonly="readonly" maxlength="50" class="input-large Wdate "
                                       value="<fmt:formatDate value="${findInvioceCondition.startDate}" pattern="yyyy-MM-dd"/>"
                                       onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
                            </li>
                            <li>
                                <label>发票代码：</label>
                                <form:input path="fpdm" value="${findInvioceCondition.fpdm}" htmlEscape="false" maxlength="10" class="input-medium"/>
                            </li>
                            <li>
                                <label>发票号码：</label>
                                <form:input path="fphm" value="${findInvioceCondition.fphm}" htmlEscape="false" maxlength="8" class="input-medium"/>
                            </li>
                            <li class="btns">
                                <input id="btnSubmit" class="btn btn-warning" type="submit" value="查询"/>
                            </li>
                        </ul>
                    </form:form>
                    <sys:message content="${message}"/>
                    <div  class="tableTHwidth">
                        <table  class="table table-striped tablestyle" >
                        </table>
                    </div>
                    <div class="tableHeight2">
                        <table id="contentTable" class="table table-striped tablestyle">
                            <thead>
                            <tr>
                                <th>操作</th>
                                <th>发票状态</th>
                                <th>发票代码</th>
                                <th>发票号码</th>
                                <th>上传状态</th>
                                <th>客户名称</th>
                                <th>主要商品名称</th>
                                <th>税额</th>
                                <th>合计税额</th>
                                <th>价税合计</th>
                                <th>原发票代码</th>
                                <th>通知单编号</th>
                                <th>开票人</th>
                                <th>开票日期</th>
                                <th>作废人</th>
                                <th>作废日期</th>
                                <th>客户识别号</th>
                                <th>清单标识</th>
                            </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${list}" var="searchInvioceInfo">
                            <tr>
                                <td>
                                    <a onclick="inviladTip('${searchInvioceInfo.fpdm}','${searchInvioceInfo.fphm}','${searchInvioceInfo.hjje}')">作废</a>
                                    <a onclick="reDoPrintTip('${searchInvioceInfo.fpdm}','${searchInvioceInfo.fphm}')">补打</a>
                                </td>
                                <td>${searchInvioceInfo.fpzt}</td>
                                <td>${searchInvioceInfo.fpdm}</td>
                                <td>${searchInvioceInfo.fphm}</td>
                                <td>${searchInvioceInfo.scbz}</td>
                                <td>${searchInvioceInfo.ghdwmc}</td>
                                <td>${searchInvioceInfo.zyspmc}</td>
                                <td>${searchInvioceInfo.hjse}</td>
                                <td>${searchInvioceInfo.hjje}</td>
                                <td>${searchInvioceInfo.jshj}</td>
                                <td>${searchInvioceInfo.yfpdm}</td>
                                <td>${searchInvioceInfo.tzdbh}</td>
                                <td>${searchInvioceInfo.kpr}</td>
                                <td>${searchInvioceInfo.kprq}</td>
                                <td>${searchInvioceInfo.zfr}</td>
                                <td>${searchInvioceInfo.zfrq}</td>
                                <td>${searchInvioceInfo.ghdwsbh}</td>
                                <td>${searchInvioceInfo.qdbz}</td>
                            </tr>
                        </c:forEach>
                        <tr>
                            <td>
                                合计 ：
                            </td>
                            <td>
                                ${total}
                            </td>
                        </tr>
                        </tbody>

                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" style="display: none">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">发票作废</h4>
            </div>
            <div class="modal-body">
                <form id="inviladForm" >
                    <input id="inviladContent.kpzdbs" name="inviladContent.kpzdbs" type="hidden" value="">
                    <div class="form-group">
                        <label for="inviladFplxdm" class="control-label">发票类型:</label>
                        <input name="inviladContent.fplxdm" type="text" class="form-control" id="inviladFplxdm" readonly="true" >
                    </div>
                    <div class="form-group">
                        <label for="inviladFpdm" class="control-label">发票代码:</label>
                        <input name="inviladContent.fpdm" type="text" class="form-control" id="inviladFpdm" readonly="true" >
                    </div>
                    <div class="form-group">
                        <label for="inviladFphm" class="control-label">发票号码:</label>
                        <input name="inviladContent.fphm" type="text" class="form-control" id="inviladFphm" readonly="true">
                    </div>
                    <div class="form-group">
                        <label for="inviladHjje" class="control-label">合计金额:</label>
                        <input name="inviladContent.hjje" type="text" class="form-control" id="inviladHjje" readonly="true">
                    </div>
                    <div class="form-group">
                        <label  class="control-label">作废类型:</label> </br>
                        <input type="radio" name="inviladContent.zflx" value="1" checked>已开票作废
                        <input type="radio" name="inviladContent.zflx" value="0" >空白票作废
                    </div>
                    <div class="form-group">
                        <label for="inviladZfr" class="control-label">作废人:</label>
                        <input name="inviladContent.zfr" type="text" class="form-control" id="inviladZfr" placeholder="作废人">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Colse</button>
                <button id="invilad" type="button" class="btn btn-primary"  onclick="invilad()">作废发票</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


<div class="modal fade" id="reDoPrintModal" tabindex="-1" role="dialog" style="display: none">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">发票补打</h4>
            </div>
            <div class="modal-body">
                    <div class="form-group">
                        <h4 class="modal-title">确定补打这张发票吗？</h4>
                    </div>
                    <div class="form-group">
                        <label for="reprintFpdm" class="control-label">发票代码:</label>
                        <input name="fpdm" type="text" class="form-control" id="reprintFpdm" readonly="true">
                    </div>
                    <div class="form-group">
                        <label for="reprintFphm" class="control-label">发票号码:</label>
                        <input name="fphm" type="text" class="form-control" id="reprintFphm" readonly="true">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button id="invilad" type="button" class="btn btn-primary"  onclick="reDoPrint()">补打发票</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<script type="text/javascript">
    $(document).ready(function () {

    })


    function inviladTip(fpdm,fphm,hjje) {
        var fplxdm = $("#fplxdm").val();
        var kpzdbs = $("#kpzdbs").val();
        $("#inviladContent\\.kpzdbs").val(kpzdbs);
        $("#inviladFplxdm").val(fplxdm);
        $("#inviladFpdm").val(fpdm);
        $("#inviladFphm").val(fphm);
        $("#inviladHjje").val(hjje);
        $('#exampleModal').modal('show');
    }



    function reDoPrintTip(fpdm,fphm) {
        $("#reprintFpdm").val(fpdm);
        $("#reprintFphm").val(fphm);
        $('#reDoPrintModal').modal('show');
    }

    function invilad() {

        var queryString = $('#inviladForm').formSerialize();
        console.log(queryString);
        $.ajax({

            type : "POST",  //提交方式
            url : "${ctx}/invioce/inviladInvioce",//路径
            data : queryString,
            success : function(result) {//返回数据根据结果进行相应的处
                SetParameter();
                doOperate(result);

            }

        })
    }

    function doOperate(result){
        console.log(result);
        var sInputInfo = result;
        try
        {
            ret = sk.Operate(sInputInfo);
            alert(ret);
        }
        catch(e)
        {
            alert(e.message + ",errno:" + e.number);
        }
    }

    function SetParameter()
    {
        var sInputInfo =
            "<?xml version=\"1.0\" encoding=\"gbk\"?>\r\n" +
            "<business id=\"20001\" comment=\"参数设置\">\r\n" +
            "<body yylxdm=\"1\">\r\n" +
            "<servletip>124.225.17.145</servletip>\r\n" +
            "<servletport>8082</servletport>\r\n" +
            "<keypwd>88888888</keypwd>\r\n" +
            "</body>\r\n" +
            "</business>";
        console.log(sInputInfo);
        try
        {
            ret = sk.Operate(sInputInfo);
        }
        catch(e)
        {
            alert(e.message + ",errno:" + e.number);
        }
    }

    function reDoPrint() {
        var fpdm = $("#reprintFpdm").val();
        var fphm = $("#reprintFphm").val();
        console.log(fpdm);
        console.log(fphm);
        $.ajax({
            async : false,
            type : "POST",  //提交方式
            url : "${ctx}/invioce/prereDo",//路径
            data : {
                "fplxdm":$("#fplxdm").val(),
                "fpdm":fpdm,
                "fphm":fphm
            },
            success : function(result) {//返回数据根据结果进行相应的处
                SetParameter();
                SetMargin();
                inviladInvioce(result);

            }

        })
    }

    function inviladInvioce(result){
        console.log(result);
        var sInputInfo = result;
        try
        {
            ret = sk.Operate(sInputInfo);
            alert(ret);
        }
        catch(e)
        {
            alert(e.message + ",errno:" + e.number);
        }
    }

    function SetMargin(){

        $.ajax({
            async : false,
            type : "POST",  //提交方式
            url : "${ctx}/invioce/getMarginProperty",//路径
            data : {
                "fplxdm":$("#fplxdm").val(),
            },
            success : function(result) {//返回数据根据结果进行相应的处
                doOperate(result);
            }

        })
    }




</script>

</body>
</html>